﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace PeopleCounterWidget
{
    /// <summary>
    /// Interaction logic for PeopleCounter.xaml
    /// </summary>
    public partial class PeopleCounter : UserControl
    {
        public PeopleCounter()
        {
            InitializeComponent();
        }

        private int number;
        public int Number
        {
            get
            {
                return number;
            }
            set
            {
                number = value;
                DisplayNumber(number.ToString());
            }
        }

        private void DisplayNumber(string number)
        {
            if (number.Length >= 1)
            {
                Text4.Text = number.Substring(number.Length - 1, 1);
            }
            else
            {
                Text4.Text = "";
            }

            if (number.Length >= 2)
            {
                Text3.Text = number.Substring(number.Length - 2, 1);
            }
            else
            {
                Text3.Text = "";
            }

            if (number.Length >= 3)
            {
                Text2.Text = number.Substring(number.Length - 3, 1);
            }
            else
            {
                Text2.Text = "";
            }
            
            if (number.Length >= 4)
            {
                Text1.Text = number.Substring(number.Length - 4, 1);
            }
            else
            {
                Text1.Text = "";
            }
        }
    }
}
